
layui.use(['form','table'],function(){


    $ = layui.jquery;
    var form = layui.form,
        table = layui.table;



    //用户列表
    var tableIns=table.render({
        elem: '#logInfo',
        url : '/sharepark/log/list',
        page : true,
        height : "full-100",
        limits : [10,20,30,40],
        limit : 10,
        id : "logList",
        cols : [[
            {type: "checkbox", fixed:"left", width:50},
            {field: 'loId', title: 'ID', sort: true, align:"center"},
            {field: 'loOperate', title: '操作', sort: true, align:'center'},
            {field: 'lId', title: '用户ID', sort: true, align:'center'},
            {field: 'loAddress', title: '登录IP', sort: true, align:'center'},
            {field: 'lTime', title: '时间',  sort: true, align:'center',minWidth:150}
        ]]
    });

    //搜索
    $(".search_btn").on("click",function(){
       if($(".searchVal").val() != ''){
            tableIns.reload({
                where:{
                    loOperate: $(".searchVal").val()
                }
            })
        }else{
            layer.msg("请输入搜索的内容");
        }
    });

    //批量删除
    $(".delAll_btn").click(function(){
        var checkStatus = table.checkStatus('logList'),
            data = checkStatus.data,
            ids = [];
        console.log(data);
        if(data.length > 0) {
            for (var i=0; i<data.length; i++) {
                ids.push(data[i].loId);
            }
            layer.confirm('确定删除选中的日志？', {icon: 3, title: '提示信息'}, function (index) {
                var param = "params=" + ids;
                $.post("/sharepark/log/delete",
                    param,
                function(data){
                    tableIns.reload();
                    layer.msg("成功删除"+ids.length+"条数据");
                    layer.close(index);
                })
            })
        }else{
            layer.msg("请选择需要删除的日志");
        }
    })

})
